package chapter3.five;

import chapter3.BiNode;

public class Test {

	
	public static boolean isEqual(BiNode root1,BiNode root2) {
		if(root1==null && root2==null) {
			return true;
		}
		if(root1==null || root2==null) {
			return false;
		}
		
		if(root1.data==root2.data) {
			return isEqual(root1.lChild,root2.lChild) && isEqual(root1.rChild,root2.rChild);
		}else {
			return false;
		}
		
		
	}
	
	public static void main(String[] args) {
		BiNode root1 = chapter3.four.Test.constructTree();
		BiNode root2 = chapter3.four.Test.constructTree();
		
		boolean equal = isEqual(root1, root2);
		
		if(equal) {
			System.out.println("两棵树相等！");
		}else {
			System.out.println("两棵树不相等！");
		}
		
	}
}
